<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .imgs {
        width:200px;
        height:200px;
       }

    </style>
</head>
<body>
    <img src="./0.jpeg" alt="" class="imgs">
    <div>
        <button class="left">上一张</button>
        <button class="right">下一张</button>
    </div>
<script>
    const imgs=document.querySelector('.imgs');
    const rights=document.querySelector('.right');
    const lefts=document.querySelector('.left');
    var sum=0;
    rights.onclick=function(){
        if(sum<5)
        {
            sum++;
        }
        imgs.src=`./${sum}.jpeg`;
    };
    lefts.onclick=function(){
            if(sum>0)
        {
            sum--;  
        }
            imgs.src=`./${sum}.jpeg`;
        };

</script>
</body>
</html>